import java.util.concurrent.*;

public class Demo34 {
    //Java中
    public static void main(String[] args) {
        //创建一个普通的线程池
        //用于很多遍短时间工作的工作任务的线程池
        ExecutorService service = Executors.newCachedThreadPool();
        ExecutorService service1 = Executors.newFixedThreadPool(10);   //可以固定大小的线程池
        ExecutorService service2 = Executors.newSingleThreadExecutor();  //创建一个只包含单个线程的线程池
        ExecutorService service3 = Executors.newScheduledThreadPool(4);// 创建一个固定线程个数,但是任务延时执行的线程池

        //创建一个自定义线程池
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10,
                20,10000, TimeUnit.HOURS,new ArrayBlockingQueue<Runnable>(1000));



        for (int i = 0; i < 10000; i++) {
            int id = i;
            service.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello" + id + "," + Thread.currentThread().getName());
                }
            });
        }
    }
}
